package kr.co.bettersoft.pushchat.adapter;

import java.util.List;

import kr.co.bettersoft.pushchat.activity.R;
import kr.co.bettersoft.pushchat.domain.PushChatFriend;
import kr.co.bettersoft.pushchat.domain.PushChatMember;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
/**
 * 친구 목록을 화면에 적용할 때 사용할 아답터
 * @author blue
 *
 */
public class PushChatFriendListAdapter extends BaseAdapter {
	String TAG = "PushChatMemberListAdapter";
	private Context context;
	private final List<PushChatFriend> entries;

	public PushChatFriendListAdapter(Context context, List<PushChatFriend> entriesFn) {		
		this.context = context;
		this.entries = entriesFn;
	}
	Boolean blued = false;
	public View getView(int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View listView;
		if (convertView == null) {
			listView = new View(context);
			listView = inflater.inflate(R.layout.adapter_pushchat_friend_list, null);
		} else {
			listView = (View) convertView;
		}

		// set value into textview

		ImageView thumbnailImg = (ImageView) listView.findViewById(R.id.member_thumbnail_img);
		TextView memberIdTxt = (TextView) listView.findViewById(R.id.member_id_txt);
		TextView memberCommentTxt = (TextView) listView.findViewById(R.id.member_comment_txt);
		if(((PushChatFriend)entries.get(position)).getThumbnail()==null){
			thumbnailImg.setImageDrawable(context.getResources().getDrawable(R.drawable.empty_member));
		}else{
			thumbnailImg.setImageBitmap(((PushChatFriend)entries.get(position)).getThumbnail());
		}
		memberIdTxt.setText(((PushChatFriend)entries.get(position)).getNickName()+"("+((PushChatFriend)entries.get(position)).getMemberId()+")");
		memberCommentTxt.setText(((PushChatFriend)entries.get(position)).getComment());
		//		TextView textView1 = (TextView) listView.findViewById(R.id.chat_member_list_nickname);
		//		textView1.setText(((PushChatMember)entries.get(position)).getNickName()+"("+((PushChatMember)entries.get(position)).getMemberId()+")");

		return listView;
	}

	@Override
	public int getCount() {
		return entries.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

}